<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    button.active{
      background-color: rgb(190, 164, 44);
    }
    .content{
      width: 200px;
      height: 200px;
      border: 1px solid #333;
      font-size: 40px;
      text-align: center;
      line-height: 200px;
    }
  </style>
</head>
<body>
  <div id="app">
    <button 
      v-for="(tab,index) in tabs"
      @click="switchTab(index)" 
      :class="{active: activeIndex === index}"
    >{{tab.title}}</button>
    
    <div 
      v-for="(tab,index) in tabs"
      v-show="activeIndex === index" 
      class="content">{{tab.content}}</div>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        tabs: [
          {
            title: '标题1',
            content: '内容1'
          },
          {
            title: '标题2',
            content: '内容2'
          },
          {
            title: '标题3',
            content: '内容3'
          },
          {
            title: '标题4',
            content: '内容4'
          }
        ],
        activeIndex: 0 // 定义动态下标作为条件
      },
      methods: {
        switchTab(index){
          this.activeIndex = index;
        }
      }
    })
  </script>
</body>
</html>